package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.CircuitUsesHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

/**
 * @author xueyf
 * @Description
 * @Date 2021/5/25 15:35
 */
@Service
@AttrHandler(CircuitUsesHandler.class)
public class CircuitUsesLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    /**
     * 电路用途
     */
    private static final String CIRCUIT_USES = "2_0000006";
    /**
     * 点到点
     */
    private static final String ONE_TO_ONE = "1_0000117";

    /**
     * VLAN是否划分属性
     */
    private static final String VLAN_PARTITION_FLAG  = "2_0000033";
    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr vlanPartitionFlag = kiteInst.getAttr(VLAN_PARTITION_FLAG);
        if(CIRCUIT_USES.equals(kiteAttr.getFieldName())){
            if(ONE_TO_ONE.equals(kiteAttr.getValue())){
                vlanPartitionFlag.setIsNull(KeyConsts.IFTRUE_T);
            }else {
                vlanPartitionFlag.setIsNull(KeyConsts.IFTRUE_F);
            }
        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
